<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  "use strict"; {
    function truncate(str, num) {
      // 请把你的代码写在这里
      if (num < str.length) {
        if (num >= 3) {
          str = str.slice(0, num - 3) + "...";
        } else {
          str = str.slice(0, num) + "...";
        }
      }
      return str;
    }
    truncate("A-tisket a-tasket A green and yellow basket", 11);
    let str = `我也可以谈，我也可以爱国`;
    const truncate = (str, num) => {
      if (str.length > num) {
        str.splice();
      };
    };
  };
</script>

</html>